'use strict';

const Service = require('egg').Service;

class HellowordService extends Service {
  async delete(ctx) {
    const { commentId } = ctx.query;
    const { articleId } = ctx.params;
    // 删除操作
    console.log(articleId, commentId);
    return {
      code: 200,
      data: {},
      message: `${articleId} 文章下的 id 为 ${commentId} 的评论已被删除`,
    };
  }

  // 随机获取一条记录 进行缓存
  async randomAsk() {
    const { ctx, app } = this;
    // 随机查询
    const res = await ctx.sqlModel.Sentence.findOne({
      order: [ app.Sequelize.literal('rand()') ],
    });
    return res;
  }
}
module.exports = HellowordService;
